package day7.timer.impl2;

import java.util.concurrent.PriorityBlockingQueue;

public class MyTimer {
    private final PriorityBlockingQueue<MyTimerTask> queue = new PriorityBlockingQueue<>();

    public MyTimer() {
        Worker worker = new Worker(queue);
        worker.start();
    }

    public void schedule(MyTimerTask task, long delay) {
        task.runAt = System.currentTimeMillis() + delay;
        queue.put(task);
    }
}
